import { Injectable } from "@angular/core";
import { Action } from "../../../../adep/flux";
import { HttpClient } from "@angular/common/http";

export enum BankChartActionType {
    REQUEST_DATA = 'BANK_CHART_ACTION_TYPE_REQUEST_DATA'
}

@Injectable()
export class BankChartAction extends Action {

    constructor(private http: HttpClient) {
        super();
    }

    public requestData() {
        this.http.get('assets/mock/chart.reception.json')
        .subscribe((response: any) => {
            this.dispatcher.dispatch({
                actionType: BankChartActionType.REQUEST_DATA,
                data: { data: response.questions, pageIndex: 0 }
            });
        })
    }
}